package com.ibo.htlivecamera.app;

import android.app.Application;
import android.content.SharedPreferences;

import org.xutils.x;

public class MyApplication extends Application {
    private static MyApplication app;

    public MyApplication() {
        app = this;
    }

    public static MyApplication getInstance() {
        return app;
    }

    @Override
    public void onCreate() {
        super.onCreate();


        loadIp();

        x.Ext.init(this);
        x.Ext.setDebug(false); //输出debug日志，开启会影响性能
    }

    public void setIp(String text) {
        Constants.HOST = text;
        getSharedPreferences("config", MODE_PRIVATE).edit().putString("ip", text).apply();
    }

    public void loadIp() {
        String ip = getSharedPreferences("config", MODE_PRIVATE).getString("ip", "");
        if (ip != null && !ip.isEmpty()) {
            Constants.HOST = ip;
        }
    }

}
